<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 1. 编写函数获得随机的颜色字符串（#20cd4f）； -->
   <script>
    function color(){
        var str="0123456789abcdef";
        var result="";
        for(var i=0;i<6;i++){
         var num=parseInt(Math.random()*str.length);
         result += str[num];
        }
        result="#"+result;
        return result;
    }
    console.log(color());
   </script>
</body>

</html>